<template>
  <div class="store-group">
    <!-- 店铺头部 -->
    <div class="store-header">
      <div class="store-checkbox">
        <el-checkbox 
          :model-value="store.checked" 
          @change="(val: boolean) => $emit('store-check-change', store.id, val)"
          class="store-select"
        />
      </div>
      <div class="store-info">
        <span class="store-name">{{ store.name }}</span>
        <span class="store-type" v-if="store.type">{{ store.type }}</span>
      </div>
    </div>
    
    <!-- 店铺商品列表 -->
    <div class="store-items">
      <CartItem
        v-for="item in store.items"
        :key="item.id"
        :item="item"
        @check-change="(id, checked) => $emit('item-check-change', id, checked)"
        @quantity-change="(id, num) => $emit('item-quantity-change', id, num)"
        @move-favorite="(id) => $emit('item-move-favorite', id)"
        @delete="(id) => $emit('item-delete', id)"
      />
    </div>
  </div>
</template>

<script setup lang="ts">
import CartItem from './CartItem.vue'
import type { CartItemData } from './CartItem.vue'

export interface StoreData {
  id: string
  name: string
  type?: string
  checked: boolean
  items: CartItemData[]
}

const props = defineProps<{
  store: StoreData
  loading?: boolean
}>()
//使用props
 props.store.items.length === 0


</script>

<style scoped lang="scss">
.store-group {
  margin-bottom: 0.25rem;
  background: transparent;
  border-bottom: 1px solid #f0f0f0;
}

.store-header {
  display: flex;
  align-items: center;
  padding: 0.5rem 0.75rem;
  background: transparent;
  border-bottom: 1px solid #f5f5f5;
  
  .store-checkbox {
    margin-right: 0.75rem;
    
    .store-select {
      :deep(.el-checkbox__input.is-checked .el-checkbox__inner) {
        background-color: #ff6a00; // 改为 #ff6a00
        border-color: #ff6a00;
      }
    }
  }
  
  .store-info {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    
    .store-name {
      font-size: 0.8125rem;
      font-weight: 500;
      color: #333;
      transition: all 0.3s ease;
      
      &:hover {
        color: #ff6a00; // 改为 #ff6a00
        transform: translateX(2px);
      }
    }
    
    .store-type {
      font-size: 0.7rem;
      color: #fff;
      background: #ff6a00; // 改为 #ff6a00
      padding: 0.125rem 0.25rem;
      border-radius: 2px;
      transition: all 0.3s ease;
      
      &:hover {
        transform: translateY(-1px);
        box-shadow: 0 1px 3px rgba(255, 106, 0, 0.3);
      }
    }
  }
}

.store-items {
  padding: 0;
  
  .cart-item:last-child {
    margin-bottom: 0;
  }
}
</style>
